import numbro from 'numbro'
import VueHighcharts from 'vue2-highcharts'


//presto集群任务图
export const barGraphPrestoJobOptions = {
  chart: {
    backgroundColor: null,
    type: 'column',
    marginRight: 10
  },
  title: {
    text: '集群任务趋势'
  },
  xAxis: [
    {
      categories: [],
      labels: {
        step: 3
      }
    }
  ],
  yAxis: {
    allowDecimals: false,
    min: 0,
    title: {
      text: '数量（个）'
    }
  },
  tooltip: {
    shared: true,
    formatter: function () {
      var s = '<b>' + this.x + '</b>';
      $.each(this.points, function () {
        s += '<br/>' + this.series.name + ': ' +
          this.y + '个';
      });
      return s;
    }
  },
  plotOptions: {
    column: {
      stacking: 'normal'
    }
  },
  series: [{
    name: '失败',
    data: [],
    color: '#ff4949',
    stack: 'male'
  }, {
    name: '成功',
    data: [],
    color: 'rgb(163, 225, 212)',
    stack: 'male'
  }],
  credits: {
    enabled: false
  },
  exporting: {
    enabled: false
  }
}

export const piePrestoJdbcJobOptions = {
  chart: {
    plotBackgroundColor: null,
    plotBorderWidth: null,
    plotShadow: false
  },
  title: {
    floating: false,
    text: ''
  },
  legend: {
    align: 'left',
    verticalAlign: 'top'
  },
  tooltip: {
    formatter: function () {
      let $x, $y0, $y1
      if (this.key) {
        $x = '<span>' + this.key + '</span>'
      }
      if (this.percentage) {
        $y0 =
          '<br/><span>百分比: ' +
          numbro(this.percentage).format('0.00') +
          '%</span>'
      }
      if (this.y) {
        $y1 = ' <br/><span>个数：' + this.y + '</span>'
      }
      return $x + $y0 + $y1
    }
  },
  plotOptions: {
    pie: {
      allowPointSelect: true,
      colors: [
        '#a3e1d4',
        '#dedede',
        '#9CC3DA',
        '#1c84c6',
        '#23c6c8',
        '#f8ac59'
      ],
      cursor: 'pointer',
      showInLegend: true,
      dataLabels: {
        enabled: true,
        formatter: function () {
          let $x, $y0
          if (this.key) {
            $x = '<span>' + this.key + '</span>'
          }
          if (this.percentage) {
            $y0 =
              '<span> ' +
              numbro(this.percentage).format('0.00') +
              '%</span>'
          }
          return $x + $y0
        },
        style: {
          color: 'grep'
        }
      }
    }
  },
  credits: {
    enabled: false
  },
  series: []
}

export const piePrestoDqueryJobOptions = {
  chart: {
    plotBackgroundColor: null,
    plotBorderWidth: null,
    plotShadow: false
  },
  title: {
    floating: false,
    text: ''
  },
  legend: {
    align: 'left',
    verticalAlign: 'top'
  },
  tooltip: {
    formatter: function () {
      let $x, $y0, $y1
      if (this.key) {
        $x = '<span>' + this.key + '</span>'
      }
      if (this.percentage) {
        $y0 =
          '<br/><span>百分比: ' +
          numbro(this.percentage).format('0.00') +
          '%</span>'
      }
      if (this.y) {
        $y1 = ' <br/><span>个数：' + this.y + '</span>'
      }
      return $x + $y0 + $y1
    }
  },
  plotOptions: {
    pie: {
      allowPointSelect: true,
      colors: [
        '#a3e1d4',
        '#dedede',
        '#9CC3DA',
        '#1c84c6',
        '#23c6c8',
        '#f8ac59'
      ],
      cursor: 'pointer',
      showInLegend: true,
      dataLabels: {
        enabled: true,
        formatter: function () {
          let $x, $y0
          if (this.key) {
            $x = '<span>' + this.key + '</span>'
          }
          if (this.percentage) {
            $y0 =
              '<span> ' +
              numbro(this.percentage).format('0.00') +
              '%</span>'
          }
          return $x + $y0
        },
        style: {
          color: 'grep'
        }
      }
    }
  },
  credits: {
    enabled: false
  },
  series: []
}
